<?php

/**
 * photo actions.
 *
 * @package    sfwixet
 * @subpackage photo
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class profileCommentsComponents extends sfComponents
{
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
  public function executeIndex(sfWebRequest $request)
  {

  	  	if(is_numeric($request->getParameter("id")))
  			$profile = Doctrine::getTable("Profile")->find($request->getParameter("id",$this->getUser()->getId()));
  		else
  			$profile = $this->getUser()->getGuardUser()->getProfile();
  		
  	if($profile instanceof Profile)
  	{
  		$pager = $profile->getComments($request->getParameter("page",1),20);
	  		
  		$this->comments = $pager->getResults();
  		$this->pageCount = $pager->getLastPage();
  	}
  	else
  	{
  		$this->comments = array();
  		$this->pageCount = 0;
  		//$this->getResponse()->setStatusCode(404,"prohibido");
  	}
  }
  
  public function executeTitle(sfWebRequest $request)
  {
  	$this->title=__("Comments");
  }
}
